<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MTB CAT1 Peripheral driver library: SAR (Successive-Approximation Register Analogue to Digital Converter)</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="IFXCYP_one-line.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">MTB CAT1 Peripheral driver library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__group__hppass__sar.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#groups">API Reference</a>  </div>
  <div class="headertitle">
<div class="title">SAR (Successive-Approximation Register Analogue to Digital Converter)<div class="ingroups"><a class="el" href="group__group__hppass.html">HPPASS       (High Performance Programmable Analog Sub-System)</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">General Description</h2>
<p>This driver provides API functions to configure the SAR ADC subsystem within High Power Programmable Analog Sub-System. </p>
<h1><a class="anchor" id="group_hppass_sar_initialization"></a>
HW Initialization and Enable</h1>
<p>Configuration snippet for one shot SAR application. Startup SAR state enables SAR. One shot SAR measurement state triggers SAR to perform one measurement.</p>
<div class="fragment"><div class="line"><span class="preprocessor">#define CY_HPPASS_STARTUP_STT_NUM_ENTRIES (1U)</span></div><div class="line"><span class="preprocessor">#define CY_HPPASS_MEASURE_STT_NUM_ENTRIES (1U)</span></div><div class="line"><span class="preprocessor">#define CY_HPPASS_SAR_GROUP_TRIG  (0x01U)</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">/* Startup SAR STT */</span></div><div class="line"><span class="keyword">const</span> <a class="code" href="structcy__stc__hppass__ac__stt__t.html">cy_stc_hppass_ac_stt_t</a> startupSTT =</div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__hppass__ac__stt__t.html#a714dcdb2ae8fc839ad952e27a4226618">condition</a>     = <a class="code" href="group__group__hppass__ac__enums.html#ggaea44d893e178654843f93d79240307ffa97f465d855650f7dfdb4e2924174b894">CY_HPPASS_CONDITION_FALSE</a>,</div><div class="line">    .action        = <a class="code" href="group__group__hppass__ac__enums.html#gga9666a32671385b7458ab6884c4b7a1ffacd89c6f635b4026c793a6da860350121">CY_HPPASS_ACTION_STOP</a>,</div><div class="line">    .branchStateIdx   = 0U,</div><div class="line">    .interrupt     = <span class="keyword">false</span>,</div><div class="line">    .count         = 0U,</div><div class="line">    .gpioOutUnlock = <span class="keyword">false</span>,</div><div class="line">    .gpioOutMsk       = 0U,</div><div class="line">    .csgUnlock     = {<span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>},</div><div class="line">    .csgEnable     = {<span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>},</div><div class="line">    .csgDacTrig    = {<span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>},</div><div class="line">    .sarUnlock     = <span class="keyword">true</span>,</div><div class="line">    .sarEnable     = <span class="keyword">true</span>,</div><div class="line">    .sarGrpMsk        = 0U,</div><div class="line">    .sarMux        = {{0}, {0}, {0}, {0}}</div><div class="line">};</div><div class="line"></div><div class="line"><span class="comment">/* One shot SAR measurement STT */</span></div><div class="line"><span class="keyword">const</span> <a class="code" href="structcy__stc__hppass__ac__stt__t.html">cy_stc_hppass_ac_stt_t</a> measureSTT =</div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__hppass__ac__stt__t.html#a714dcdb2ae8fc839ad952e27a4226618">condition</a>     = <a class="code" href="group__group__hppass__ac__enums.html#ggaea44d893e178654843f93d79240307ffa97f465d855650f7dfdb4e2924174b894">CY_HPPASS_CONDITION_FALSE</a>,</div><div class="line">    .action        = <a class="code" href="group__group__hppass__ac__enums.html#gga9666a32671385b7458ab6884c4b7a1ffacd89c6f635b4026c793a6da860350121">CY_HPPASS_ACTION_STOP</a>,</div><div class="line">    .branchStateIdx   = 0U,</div><div class="line">    .interrupt     = <span class="keyword">false</span>,</div><div class="line">    .count         = 0U,</div><div class="line">    .gpioOutUnlock = <span class="keyword">false</span>,</div><div class="line">    .gpioOutMsk       = 0U,</div><div class="line">    .csgUnlock     = {<span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>},</div><div class="line">    .csgEnable     = {<span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>},</div><div class="line">    .csgDacTrig    = {<span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">false</span>},</div><div class="line">    .sarUnlock     = <span class="keyword">false</span>,</div><div class="line">    .sarEnable     = <span class="keyword">false</span>,</div><div class="line">    .sarGrpMsk        = CY_HPPASS_SAR_GROUP_TRIG,</div><div class="line">    .sarMux        = {{0}, {0}, {0}, {0}}</div><div class="line">};</div><div class="line"></div><div class="line"><span class="keyword">const</span> <a class="code" href="structcy__stc__hppass__sar__grp__t.html">cy_stc_hppass_sar_grp_t</a> grpCfg =</div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__hppass__sar__grp__t.html#a352c1fe5740afb64945f0f04dc707a0a">dirSampMsk</a>   = <a class="code" href="group__group__hppass__sar__direct__samplers.html#gaca3d7ea9142b4b797c01e88c2a98624d">CY_HPPASS_SAR_DIRECT_SAMP_0</a>,</div><div class="line">    .muxSampMsk   = <a class="code" href="group__group__hppass__sar__muxed__samplers.html#gaf21f34172a8ec7e54b16000e73fafc21">CY_HPPASS_SAR_MUXED_SAMP_0</a> | <a class="code" href="group__group__hppass__sar__muxed__samplers.html#ga1c7a4d2f3700e836f84e51cfa372b85e">CY_HPPASS_SAR_MUXED_SAMP_1</a> | <a class="code" href="group__group__hppass__sar__muxed__samplers.html#ga0676700ddab65120c1e85e257860b00a">CY_HPPASS_SAR_MUXED_SAMP_2</a> | <a class="code" href="group__group__hppass__sar__muxed__samplers.html#ga932f973c20e6455f2710dcc5b3a5ec03">CY_HPPASS_SAR_MUXED_SAMP_3</a>,</div><div class="line">    .muxChanIdx      = {0, 0, 0, 0},</div><div class="line">    .trig     = <a class="code" href="group__group__hppass__sar__enums.html#ggafb345a3d451274c4b40309384dd07efcaf1c8e5026bb0f93d95f12a04ea073bcf">CY_HPPASS_SAR_TRIG_AC</a>,</div><div class="line">    .sampTime = <a class="code" href="group__group__hppass__sar__enums.html#ggaffa59d1aa8d36df32dca30f0afed2e0fac82612fac74208f8ac5ba8f776c0ddb2">CY_HPPASS_SAR_SAMP_TIME_0</a>,</div><div class="line">    .priority    = <span class="keyword">false</span>,</div><div class="line">    .continuous  = <span class="keyword">false</span></div><div class="line">};</div><div class="line"><a class="code" href="structcy__stc__hppass__sar__chan__t.html">cy_stc_hppass_sar_chan_t</a> chanCfg =</div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__hppass__sar__chan__t.html#a3cc40a1a5f02a50081870b542d4525b3">diff</a>     = <span class="keyword">false</span>,</div><div class="line">    .sign     = <span class="keyword">false</span>,</div><div class="line">    .avg      = <a class="code" href="group__group__hppass__sar__enums.html#ggae2f7574296597739ca43f2196bab0853a92843786edc02440f371b776a417c973">CY_HPPASS_SAR_AVG_DISABLED</a>,</div><div class="line">    .limit = <a class="code" href="group__group__hppass__sar__enums.html#gga761a8378e0f3b0eab1a27f8617d1c02eae8979b0849935acf47a6057472a8c377">CY_HPPASS_SAR_LIMIT_DISABLED</a>,</div><div class="line">    .result   = <span class="keyword">true</span>,</div><div class="line">    .fifo  = <a class="code" href="group__group__hppass__sar__enums.html#ggaf90fa2a37e0fb7ef39e80b0c8c3179e9a27b52f62b23dd390c0f3317d106ade34">CY_HPPASS_FIFO_DISABLED</a></div><div class="line">};</div><div class="line"><a class="code" href="structcy__stc__hppass__sar__t.html">cy_stc_hppass_sar_t</a> sarCfg =</div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__hppass__sar__t.html#a89d3ae8c9d968982463d1f8096d30fb4">vref</a>        = <a class="code" href="group__group__hppass__sar__enums.html#ggad2d8f05def7ce065349e30631c34144fa091c21a6de9c6099d5f7cbbbc1e1a87a">CY_HPPASS_SAR_VREF_VDDA</a>,</div><div class="line">    .lowSupply   = <span class="keyword">false</span>,</div><div class="line">    .offsetCal   = <span class="keyword">false</span>,</div><div class="line">    .linearCal   = <span class="keyword">false</span>,</div><div class="line">    .gainCal     = <span class="keyword">false</span>,</div><div class="line">    .chanId      = <span class="keyword">false</span>,</div><div class="line">    .dirSampEnMsk   = <a class="code" href="group__group__hppass__sar__direct__samplers.html#gaca3d7ea9142b4b797c01e88c2a98624d">CY_HPPASS_SAR_DIRECT_SAMP_0</a>,</div><div class="line">    .muxSampEnMsk   = <a class="code" href="group__group__hppass__sar__muxed__samplers.html#gaf21f34172a8ec7e54b16000e73fafc21">CY_HPPASS_SAR_MUXED_SAMP_0</a> | <a class="code" href="group__group__hppass__sar__muxed__samplers.html#ga1c7a4d2f3700e836f84e51cfa372b85e">CY_HPPASS_SAR_MUXED_SAMP_1</a> | <a class="code" href="group__group__hppass__sar__muxed__samplers.html#ga0676700ddab65120c1e85e257860b00a">CY_HPPASS_SAR_MUXED_SAMP_2</a> | <a class="code" href="group__group__hppass__sar__muxed__samplers.html#ga932f973c20e6455f2710dcc5b3a5ec03">CY_HPPASS_SAR_MUXED_SAMP_3</a>,</div><div class="line">    .holdCount   = 29, <span class="comment">/* Optimal value */</span></div><div class="line">    .aroute    = <span class="keyword">true</span>,</div><div class="line">    .dirSampGain = {<a class="code" href="group__group__hppass__sar__enums.html#gga11f649f48e0d846f657491a8d6a432e6a6cf95803fd841741b1815e64dc16de1e">CY_HPPASS_SAR_SAMP_GAIN_1</a>, <a class="code" href="group__group__hppass__sar__enums.html#gga11f649f48e0d846f657491a8d6a432e6a6cf95803fd841741b1815e64dc16de1e">CY_HPPASS_SAR_SAMP_GAIN_1</a>, <a class="code" href="group__group__hppass__sar__enums.html#gga11f649f48e0d846f657491a8d6a432e6a6cf95803fd841741b1815e64dc16de1e">CY_HPPASS_SAR_SAMP_GAIN_1</a>, <a class="code" href="group__group__hppass__sar__enums.html#gga11f649f48e0d846f657491a8d6a432e6a6cf95803fd841741b1815e64dc16de1e">CY_HPPASS_SAR_SAMP_GAIN_1</a>,</div><div class="line">                    <a class="code" href="group__group__hppass__sar__enums.html#gga11f649f48e0d846f657491a8d6a432e6a6cf95803fd841741b1815e64dc16de1e">CY_HPPASS_SAR_SAMP_GAIN_1</a>, <a class="code" href="group__group__hppass__sar__enums.html#gga11f649f48e0d846f657491a8d6a432e6a6cf95803fd841741b1815e64dc16de1e">CY_HPPASS_SAR_SAMP_GAIN_1</a>, <a class="code" href="group__group__hppass__sar__enums.html#gga11f649f48e0d846f657491a8d6a432e6a6cf95803fd841741b1815e64dc16de1e">CY_HPPASS_SAR_SAMP_GAIN_1</a>, <a class="code" href="group__group__hppass__sar__enums.html#gga11f649f48e0d846f657491a8d6a432e6a6cf95803fd841741b1815e64dc16de1e">CY_HPPASS_SAR_SAMP_GAIN_1</a>,</div><div class="line">                    <a class="code" href="group__group__hppass__sar__enums.html#gga11f649f48e0d846f657491a8d6a432e6a6cf95803fd841741b1815e64dc16de1e">CY_HPPASS_SAR_SAMP_GAIN_1</a>, <a class="code" href="group__group__hppass__sar__enums.html#gga11f649f48e0d846f657491a8d6a432e6a6cf95803fd841741b1815e64dc16de1e">CY_HPPASS_SAR_SAMP_GAIN_1</a>, <a class="code" href="group__group__hppass__sar__enums.html#gga11f649f48e0d846f657491a8d6a432e6a6cf95803fd841741b1815e64dc16de1e">CY_HPPASS_SAR_SAMP_GAIN_1</a>, CY_HPPASS_SAR_SAMP_GAIN_1},</div><div class="line">    .muxSampGain = {<a class="code" href="group__group__hppass__sar__enums.html#gga11f649f48e0d846f657491a8d6a432e6a6cf95803fd841741b1815e64dc16de1e">CY_HPPASS_SAR_SAMP_GAIN_1</a>, <a class="code" href="group__group__hppass__sar__enums.html#gga11f649f48e0d846f657491a8d6a432e6a6cf95803fd841741b1815e64dc16de1e">CY_HPPASS_SAR_SAMP_GAIN_1</a>, <a class="code" href="group__group__hppass__sar__enums.html#gga11f649f48e0d846f657491a8d6a432e6a6cf95803fd841741b1815e64dc16de1e">CY_HPPASS_SAR_SAMP_GAIN_1</a>, CY_HPPASS_SAR_SAMP_GAIN_1},</div><div class="line">    .sampTime    = {100, 31, 31}, <span class="comment">/* Optimal value */</span></div><div class="line">    .chan        = {&amp;chanCfg, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &amp;chanCfg, NULL,</div><div class="line">                    NULL, NULL, &amp;chanCfg, NULL, NULL, NULL, &amp;chanCfg, NULL, NULL, NULL, &amp;chanCfg, NULL, NULL, NULL},</div><div class="line">    .grp         = {&amp;grpCfg, NULL, NULL, NULL, NULL, NULL, NULL, NULL},</div><div class="line">    .limit       = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},    </div><div class="line">    .muxMode     = {<a class="code" href="group__group__hppass__sar__enums.html#ggab8d45f2bf082e466df16caed456b727aa80cd4f6f2903e96a0f035e463a0c4b3c">CY_HPPASS_SAR_MUX_SEQ</a>, <a class="code" href="group__group__hppass__sar__enums.html#ggab8d45f2bf082e466df16caed456b727aa80cd4f6f2903e96a0f035e463a0c4b3c">CY_HPPASS_SAR_MUX_SEQ</a>, <a class="code" href="group__group__hppass__sar__enums.html#ggab8d45f2bf082e466df16caed456b727aa80cd4f6f2903e96a0f035e463a0c4b3c">CY_HPPASS_SAR_MUX_SEQ</a>, CY_HPPASS_SAR_MUX_SEQ},</div><div class="line">    .fir         = {NULL, NULL},</div><div class="line">    .fifo        = NULL</div><div class="line">};</div><div class="line"><span class="comment">/* HPPASS and AC state transition table configuration, used by Cy_HPPASS_Init API */</span></div><div class="line"><span class="keyword">const</span> <a class="code" href="structcy__stc__hppass__cfg__t.html">cy_stc_hppass_cfg_t</a> cfg =</div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__hppass__cfg__t.html#a3d2448daab68ef8b7c0568a4bc41a695">ac</a> =</div><div class="line">    {</div><div class="line">        .<a class="code" href="structcy__stc__hppass__ac__t.html#a366455c9d80a2dbb04d799ea75c34230">sttEntriesNum</a> = CY_HPPASS_STARTUP_STT_NUM_ENTRIES,</div><div class="line">        .stt = &amp;startupSTT,</div><div class="line">        .gpioOutEnMsk = 0U,</div><div class="line">        .startupClkDiv = 7U,</div><div class="line">        .startup =</div><div class="line">        {</div><div class="line">            {</div><div class="line">                .<a class="code" href="structcy__stc__hppass__ac__stt__t.html#a61d4497d7a7b177242920dc0e160876f">count</a>    = 0U,</div><div class="line">                .sar      = <span class="keyword">true</span>,</div><div class="line">                .csgChan  = <span class="keyword">false</span>,</div><div class="line">                .csgSlice = <span class="keyword">false</span>,</div><div class="line">                .csgReady = <span class="keyword">false</span></div><div class="line">            },</div><div class="line">            {0},</div><div class="line">            {0},</div><div class="line">            {0}</div><div class="line">        }</div><div class="line">    },</div><div class="line">    .vref   = CY_HPPASS_VREF_LOCAL,</div><div class="line">    .csg       = NULL,</div><div class="line">    .sar       = &amp;sarCfg,</div><div class="line">    .trigIn    = {{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}},</div><div class="line">    .trigPulse = {<a class="code" href="group__group__hppass__enums.html#ggae8be0bf60b1685e83512c352328b34cca33dd2eeebd4121262cca802d77172b76">CY_HPPASS_DISABLED</a>, <a class="code" href="group__group__hppass__enums.html#ggae8be0bf60b1685e83512c352328b34cca33dd2eeebd4121262cca802d77172b76">CY_HPPASS_DISABLED</a>, <a class="code" href="group__group__hppass__enums.html#ggae8be0bf60b1685e83512c352328b34cca33dd2eeebd4121262cca802d77172b76">CY_HPPASS_DISABLED</a>, <a class="code" href="group__group__hppass__enums.html#ggae8be0bf60b1685e83512c352328b34cca33dd2eeebd4121262cca802d77172b76">CY_HPPASS_DISABLED</a>,</div><div class="line">                  <a class="code" href="group__group__hppass__enums.html#ggae8be0bf60b1685e83512c352328b34cca33dd2eeebd4121262cca802d77172b76">CY_HPPASS_DISABLED</a>, <a class="code" href="group__group__hppass__enums.html#ggae8be0bf60b1685e83512c352328b34cca33dd2eeebd4121262cca802d77172b76">CY_HPPASS_DISABLED</a>, <a class="code" href="group__group__hppass__enums.html#ggae8be0bf60b1685e83512c352328b34cca33dd2eeebd4121262cca802d77172b76">CY_HPPASS_DISABLED</a>, CY_HPPASS_DISABLED},</div><div class="line">    .trigLevel = {{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}}</div><div class="line">};</div></div><!-- fragment --><p>Functional snippet Application flow:</p><ul>
<li>Startup AC microprogram enables SAR</li>
<li>Wait for SAR READY</li>
<li>Update AC microprogram to perform single measurement on channel 0</li>
<li>Steps below are repeated in loop</li>
<li>AC triggers the SAR</li>
<li>SAR generates SAR_ENTRY_DONE</li>
<li>SAR result is stored in CHAN_RESULT register</li>
<li>CHAN_RESULT register are printed out</li>
</ul>
<div class="fragment"><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">    <span class="comment">/* Set up internal routing, pins, and clock-to-peripheral connections */</span></div><div class="line">    init_cycfg_all();</div><div class="line"></div><div class="line">    <a class="code" href="group__group__scb__uart__general__functions.html#gacbc061f623d2fafbcfffcb58c5f2db51">Cy_SCB_UART_Init</a>(UART_HW, &amp;UART_config, &amp;UART_context);</div><div class="line">    <a class="code" href="group__group__scb__uart__general__functions.html#ga503d0737dadf35620306ef3571d84905">Cy_SCB_UART_Enable</a>(UART_HW);</div><div class="line"></div><div class="line">    printf(<span class="stringliteral">&quot;Very basic HPPASS SAR Test Application Main...\r\n&quot;</span>);</div><div class="line">    <a class="code" href="group__group__gpio__functions__gpio.html#ga849c813d6771bf8d3c59b89b28a07bca">Cy_GPIO_Write</a>(LED_RED_PORT, LED_RED_PIN, 0);</div><div class="line"></div><div class="line">    <span class="comment">/* Initialize HPPASS */</span></div><div class="line">    <span class="keywordflow">if</span> (CY_HPPASS_SUCCESS != <a class="code" href="group__group__hppass__cfg__functions.html#ga8d22889d8dd8c3fd87df1db2869a6956">Cy_HPPASS_Init</a>(&amp;cfg))</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Cy_HPPASS_Init returns error\r\n&quot;</span>);</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="comment">/* enable interrupts */</span></div><div class="line">    __enable_irq();</div><div class="line"></div><div class="line">    <span class="comment">/* Set interrupt mask for Result Group 0 */</span></div><div class="line">    <a class="code" href="group__group__hppass__sar__functions.html#ga7102969241d68c2abeda3aeb01155cc6">Cy_HPPASS_SAR_Result_SetInterruptMask</a>(<a class="code" href="group__group__hppass__sar__result__interrupts.html#ga96f25ad40d97562badaa3940e40f8b86">CY_HPPASS_INTR_SAR_RESULT_GROUP_0</a>);</div><div class="line">    <span class="keywordflow">if</span> (CY_HPPASS_SUCCESS != <a class="code" href="group__group__hppass__ac__functions.html#gabbf381cbbe92e087faf4c89a549cd1d7">Cy_HPPASS_AC_Start</a>(0U, 0U))</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Cy_HPPASS_AC_Start returns error\r\n&quot;</span>);</div><div class="line">    }</div><div class="line"></div><div class="line">    printf(<span class="stringliteral">&quot;Waiting for SAR ready... \r\n&quot;</span>);</div><div class="line">    <span class="keywordflow">while</span> (!<a class="code" href="group__group__hppass__ac__functions.html#gaec00f468edc0706ae7dcb46c86332caa">Cy_HPPASS_AC_IsBlockReady</a>());</div><div class="line"></div><div class="line">    printf(<span class="stringliteral">&quot;Update STT to make one SAR measurement\r\n&quot;</span>);</div><div class="line">    <span class="keywordflow">if</span> (CY_HPPASS_SUCCESS != <a class="code" href="group__group__hppass__ac__functions.html#gac55d15867c2bd040e826a87bf4e6c69e">Cy_HPPASS_AC_UpdateStateTransitionTable</a>(CY_HPPASS_MEASURE_STT_NUM_ENTRIES, &amp;measureSTT, 0U))</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Cy_HPPASS_AC_UpdateStateTransitionTable returns error\r\n&quot;</span>);</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (CY_HPPASS_SUCCESS != <a class="code" href="group__group__hppass__ac__functions.html#gabbf381cbbe92e087faf4c89a549cd1d7">Cy_HPPASS_AC_Start</a>(0U, 0U))</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Cy_HPPASS_AC_Start returns error\r\n&quot;</span>);</div><div class="line">    }</div><div class="line"></div><div class="line">    printf(<span class="stringliteral">&quot;Call one SAR measurement in loop and print the result\r\n&quot;</span>);</div><div class="line">    printf(<span class="stringliteral">&quot;Start infinite loop...\r\n&quot;</span>);</div><div class="line"></div><div class="line">    <span class="keywordflow">for</span> (;;)</div><div class="line">    {</div><div class="line">        <span class="comment">/* Polling SAR interrupt status register */</span></div><div class="line">        <span class="keywordflow">if</span> (<a class="code" href="group__group__hppass__sar__result__interrupts.html#ga96f25ad40d97562badaa3940e40f8b86">CY_HPPASS_INTR_SAR_RESULT_GROUP_0</a> == <a class="code" href="group__group__hppass__sar__functions.html#gaac98d2e357bd40e5705757bc9d863557">Cy_HPPASS_SAR_Result_GetInterruptStatus</a>())</div><div class="line">        {</div><div class="line">            <span class="comment">/* Clear interrupt for Result Group 0 */</span></div><div class="line">            <a class="code" href="group__group__hppass__sar__functions.html#ga5006b9e96c29a04b98946d7a08dbcce6">Cy_HPPASS_SAR_Result_ClearInterrupt</a>(<a class="code" href="group__group__hppass__sar__result__interrupts.html#ga96f25ad40d97562badaa3940e40f8b86">CY_HPPASS_INTR_SAR_RESULT_GROUP_0</a>);</div><div class="line">            <a class="code" href="group__group__gpio__functions__gpio.html#ga35373fa4e131e73153422ef0138bb50b">Cy_GPIO_Inv</a>(LED_RED_PORT, LED_RED_PIN);</div><div class="line"></div><div class="line">            <span class="comment">/* Read channel 0 measurement result */</span></div><div class="line">            printf(<span class="stringliteral">&quot;SAR0 Result: %x     &quot;</span>, <a class="code" href="group__group__hppass__sar__chan.html#gaea7bbb3947dc53f845f8f4955d678187">Cy_HPPASS_SAR_Result_ChannelRead</a>(0));</div><div class="line">            printf(<span class="stringliteral">&quot;SAR12 Result: %x     &quot;</span>, <a class="code" href="group__group__hppass__sar__chan.html#gaea7bbb3947dc53f845f8f4955d678187">Cy_HPPASS_SAR_Result_ChannelRead</a>(12));</div><div class="line">            printf(<span class="stringliteral">&quot;SAR16 Result: %x     &quot;</span>, <a class="code" href="group__group__hppass__sar__chan.html#gaea7bbb3947dc53f845f8f4955d678187">Cy_HPPASS_SAR_Result_ChannelRead</a>(16));</div><div class="line">            printf(<span class="stringliteral">&quot;SAR20 Result: %x     &quot;</span>, <a class="code" href="group__group__hppass__sar__chan.html#gaea7bbb3947dc53f845f8f4955d678187">Cy_HPPASS_SAR_Result_ChannelRead</a>(20));</div><div class="line">            printf(<span class="stringliteral">&quot;SAR24 Result: %x\r\n&quot;</span>, <a class="code" href="group__group__hppass__sar__chan.html#gaea7bbb3947dc53f845f8f4955d678187">Cy_HPPASS_SAR_Result_ChannelRead</a>(24));</div><div class="line">            <a class="code" href="group__group__syslib__functions.html#gaad1c32546fdb0e3c6fa8b46fb95843b5">Cy_SysLib_Delay</a>(1000);</div><div class="line"></div><div class="line">            <span class="keywordflow">if</span> (CY_HPPASS_SUCCESS != <a class="code" href="group__group__hppass__ac__functions.html#gabbf381cbbe92e087faf4c89a549cd1d7">Cy_HPPASS_AC_Start</a>(0U, 0U))</div><div class="line">            {</div><div class="line">                printf(<span class="stringliteral">&quot;Cy_HPPASS_AC_Start returns error\r\n&quot;</span>);</div><div class="line">            }</div><div class="line">        }</div><div class="line">    }</div><div class="line">}</div></div><!-- fragment --> <h1><a class="anchor" id="group_hppass_sar_interrupt"></a>
Interrupt Configuration and Initialization</h1>
<p>To configure the SAR Group or Results interrupts in addition to the SAR and AC configuration tables, as shown in the snippet above, declare your own interrupt configuration structure for each interrupt source, for example: </p><div class="fragment"><div class="line"><span class="keyword">const</span> <a class="code" href="structcy__stc__sysint__t.html">cy_stc_sysint_t</a> sarGroup0Intr =</div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__sysint__t.html#a204a8f07adf056c8d3dd818136da853f">intrSrc</a> = pass_interrupt_sar_entry_done_0_IRQn,</div><div class="line">    .intrPriority = 0x02</div><div class="line">};</div><div class="line"></div><div class="line"><span class="keyword">const</span> <a class="code" href="structcy__stc__sysint__t.html">cy_stc_sysint_t</a> sarResultsIntr =</div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__sysint__t.html#a204a8f07adf056c8d3dd818136da853f">intrSrc</a> = pass_interrupt_sar_results_IRQn,</div><div class="line">    .intrPriority = 0x03</div><div class="line">};</div></div><!-- fragment --><p>and initialize those configurations in the executable code. That code can be designed as a separate function (see the snippet below): </p><div class="fragment"><div class="line"><span class="comment">/* Initialize SAR and AC interrupts in HPPASS */</span></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> My_HPPASS_Interrupt_Config()</div><div class="line">{</div><div class="line">    <span class="comment">/* Initialize interrupt channels */</span></div><div class="line">    <a class="code" href="group__group__sysint__functions.html#gab2ff6820a898e9af3f780000054eea5d">Cy_SysInt_Init</a>(&amp;sarGroup0Intr, Cy_HPPASS_SAR_Group0_Isr);</div><div class="line">    <a class="code" href="group__group__sysint__functions.html#gab2ff6820a898e9af3f780000054eea5d">Cy_SysInt_Init</a>(&amp;sarResultsIntr, Cy_HPPASS_SAR_Results_Isr);</div><div class="line">    <a class="code" href="group__group__sysint__functions.html#gab2ff6820a898e9af3f780000054eea5d">Cy_SysInt_Init</a>(&amp;sarLimit0Intr, Cy_HPPASS_SAR_Limit0_Isr);</div><div class="line">    <a class="code" href="group__group__sysint__functions.html#gab2ff6820a898e9af3f780000054eea5d">Cy_SysInt_Init</a>(&amp;sarLimitsIntr, Cy_HPPASS_SAR_Limits_Isr);</div><div class="line">    <a class="code" href="group__group__sysint__functions.html#gab2ff6820a898e9af3f780000054eea5d">Cy_SysInt_Init</a>(&amp;hppassMMIOIntr, Cy_HPPASS_MMIO_Combined_Isr);</div><div class="line"></div><div class="line">    <span class="comment">/* Set interrupt mask */</span></div><div class="line">    <a class="code" href="group__group__hppass__sar__functions.html#ga7102969241d68c2abeda3aeb01155cc6">Cy_HPPASS_SAR_Result_SetInterruptMask</a>(<a class="code" href="group__group__hppass__sar__result__interrupts.html#ga96f25ad40d97562badaa3940e40f8b86">CY_HPPASS_INTR_SAR_RESULT_GROUP_0</a>);</div><div class="line">    <a class="code" href="group__group__hppass__sar__functions.html#ga7102969241d68c2abeda3aeb01155cc6">Cy_HPPASS_SAR_Result_SetInterruptMask</a>(<a class="code" href="group__group__hppass__sar__result__interrupts.html#ga96035ebdbb64aba6c495d1f8c9f78c95">CY_HPPASS_INTR_SAR_RESULT</a>);</div><div class="line">    <a class="code" href="group__group__hppass__sar__functions.html#gaccf34dc0221088859ed778aa1de3afd8">Cy_HPPASS_SAR_Limit_SetInterruptMask</a>(<a class="code" href="group__group__hppass__sar__limit__interrupts.html#ga1f57368538d99f3caf81de18b90d078e">CY_HPPASS_INTR_SAR_LIMIT_GROUP_0</a>);</div><div class="line">    <a class="code" href="group__group__hppass__sar__functions.html#gaccf34dc0221088859ed778aa1de3afd8">Cy_HPPASS_SAR_Limit_SetInterruptMask</a>(<a class="code" href="group__group__hppass__sar__limit__interrupts.html#ga0a0021a9839a5657558c9bb092ab7280">CY_HPPASS_INTR_SAR_LIMIT</a>);</div><div class="line">    <a class="code" href="group__group__hppass__rt__functions.html#ga50d87d33bc8a8336ceabd70566fd42cd">Cy_HPPASS_SetInterruptMask</a>(<a class="code" href="group__group__hppass__interrupts.html#ga09776ba2aa2cad7b71ab014b8d33f5eb">CY_HPPASS_INTR_AC_INT</a>);</div><div class="line">}</div></div><!-- fragment --><p>Also, initialize the NVIC through a separate function as well. </p><div class="fragment"><div class="line"><span class="comment">/* Clear pending AC and SAR interrupts in NVIC and Enable that interrupts */</span></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> My_NVIC_Interrupt_Enable()</div><div class="line">{</div><div class="line">    NVIC_ClearPendingIRQ(sarGroup0Intr.<a class="code" href="structcy__stc__sysint__t.html#a204a8f07adf056c8d3dd818136da853f">intrSrc</a>);</div><div class="line">    NVIC_EnableIRQ(sarGroup0Intr.<a class="code" href="structcy__stc__sysint__t.html#a204a8f07adf056c8d3dd818136da853f">intrSrc</a>);</div><div class="line"></div><div class="line">    NVIC_ClearPendingIRQ(sarResultsIntr.<a class="code" href="structcy__stc__sysint__t.html#a204a8f07adf056c8d3dd818136da853f">intrSrc</a>);</div><div class="line">    NVIC_EnableIRQ(sarResultsIntr.<a class="code" href="structcy__stc__sysint__t.html#a204a8f07adf056c8d3dd818136da853f">intrSrc</a>);</div><div class="line"></div><div class="line">    NVIC_ClearPendingIRQ(sarLimit0Intr.intrSrc);</div><div class="line">    NVIC_EnableIRQ(sarLimit0Intr.intrSrc);</div><div class="line"></div><div class="line">    NVIC_ClearPendingIRQ(sarLimitsIntr.intrSrc);</div><div class="line">    NVIC_EnableIRQ(sarLimitsIntr.intrSrc);</div><div class="line"></div><div class="line">    NVIC_ClearPendingIRQ(hppassMMIOIntr.intrSrc);</div><div class="line">    NVIC_EnableIRQ(hppassMMIOIntr.intrSrc);</div><div class="line">}</div></div><!-- fragment --><p>The interrupt service routine for each of the interrupt sources must be implemented in the project. One of those interrupt service routines is shown below: </p><div class="fragment"><div class="line"><span class="comment">/* Service Routine for Group0 interrupt of the SAR */</span></div><div class="line"><span class="keywordtype">void</span> Cy_HPPASS_SAR_Group0_Isr()</div><div class="line">{</div><div class="line">    uint32_t intStatus = <a class="code" href="group__group__hppass__sar__functions.html#gaac98d2e357bd40e5705757bc9d863557">Cy_HPPASS_SAR_Result_GetInterruptStatus</a>();</div><div class="line"></div><div class="line"><span class="comment">/* SAR Group0 Interrupt Clearing */</span></div><div class="line">    <span class="keywordflow">if</span> (0UL != (<a class="code" href="group__group__hppass__sar__result__interrupts.html#ga96f25ad40d97562badaa3940e40f8b86">CY_HPPASS_INTR_SAR_RESULT_GROUP_0</a> &amp; intStatus))</div><div class="line">    {</div><div class="line">        <span class="comment">/* The ADC results can be read here */</span></div><div class="line">        <a class="code" href="group__group__hppass__sar__functions.html#ga5006b9e96c29a04b98946d7a08dbcce6">Cy_HPPASS_SAR_Result_ClearInterrupt</a>(<a class="code" href="group__group__hppass__sar__result__interrupts.html#ga96f25ad40d97562badaa3940e40f8b86">CY_HPPASS_INTR_SAR_RESULT_GROUP_0</a>);</div><div class="line">    }</div><div class="line">}</div></div><!-- fragment --><p>The configuration and initialization sequence for SAR interrupts is shown in the snippet below: </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">     <span class="comment">/* Set up internal routing, pins, and clock-to-peripheral connections */</span></div><div class="line">    init_cycfg_all();</div><div class="line"></div><div class="line">    <a class="code" href="group__group__scb__uart__general__functions.html#gacbc061f623d2fafbcfffcb58c5f2db51">Cy_SCB_UART_Init</a>(UART_HW, &amp;UART_config, &amp;UART_context);</div><div class="line">    <a class="code" href="group__group__scb__uart__general__functions.html#ga503d0737dadf35620306ef3571d84905">Cy_SCB_UART_Enable</a>(UART_HW);</div><div class="line"></div><div class="line">    printf(<span class="stringliteral">&quot;--- HPPASS INTR Test Application ---\r\n&quot;</span>);</div><div class="line">    <a class="code" href="group__group__gpio__functions__gpio.html#ga849c813d6771bf8d3c59b89b28a07bca">Cy_GPIO_Write</a>(LED_RED_PORT, LED_RED_PIN, 0);</div><div class="line"></div><div class="line">    printf(<span class="stringliteral">&quot;Test Application Configuring...\r\n&quot;</span>);</div><div class="line">    My_HPPASS_Interrupt_Config();</div><div class="line"></div><div class="line">    __disable_irq();</div><div class="line">    My_NVIC_Interrupt_Enable();</div><div class="line"></div><div class="line">    <span class="comment">/* Initialize HPPASS */</span></div><div class="line">    <span class="keywordflow">if</span> (CY_HPPASS_SUCCESS != <a class="code" href="group__group__hppass__cfg__functions.html#ga8d22889d8dd8c3fd87df1db2869a6956">Cy_HPPASS_Init</a>(&amp;cfg))</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Cy_HPPASS_Init returns error!!!\r\n&quot;</span>);</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (CY_HPPASS_SUCCESS != <a class="code" href="group__group__hppass__ac__functions.html#gabbf381cbbe92e087faf4c89a549cd1d7">Cy_HPPASS_AC_Start</a>(0U, 0U))</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Cy_HPPASS_AC_Start returns error!!!\r\n&quot;</span>);</div><div class="line">    }</div><div class="line"></div><div class="line">    printf(<span class="stringliteral">&quot;Infinite loop Started...\r\n&quot;</span>);</div><div class="line"></div><div class="line">    <span class="comment">/* Enable interrupts */</span></div><div class="line">    __enable_irq();</div><div class="line"></div><div class="line">    <span class="keywordflow">for</span> (;;)</div><div class="line">    {</div><div class="line">    }</div><div class="line">}</div></div><!-- fragment --><p> To generate SAR Limit or Limits interrupts, configure one or more limits and determine the limit for each SAR channel if needed. </p><div class="fragment"><div class="line"><span class="comment">/* The limit crossing detection configuration */</span></div><div class="line"><span class="keyword">const</span> <a class="code" href="structcy__stc__hppass__sar__limit__t.html">cy_stc_hppass_sar_limit_t</a> limitCfg0 =</div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__hppass__sar__limit__t.html#a45dff6d7d1aa72d8c5641fcf243e03f7">cond</a> = <a class="code" href="group__group__hppass__sar__enums.html#gga17e54d717a55b3f03f172ce1fc3fa4bdaabf86805aae422c47a54306fc0248820">CY_HPPASS_SAR_COND_OUTSIDE</a>,</div><div class="line">    .low  = 0x03UL,</div><div class="line">    .high = 0xFFUL</div><div class="line">};</div></div><!-- fragment --><div class="fragment"><div class="line"><span class="comment">/* Channel Configuration */</span></div><div class="line"><span class="keyword">const</span> <a class="code" href="structcy__stc__hppass__sar__chan__t.html">cy_stc_hppass_sar_chan_t</a> chanCfg =</div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__hppass__sar__chan__t.html#a3cc40a1a5f02a50081870b542d4525b3">diff</a>     = <span class="keyword">false</span>,</div><div class="line">    .sign     = <span class="keyword">false</span>,</div><div class="line">    .avg      = <a class="code" href="group__group__hppass__sar__enums.html#ggae2f7574296597739ca43f2196bab0853a92843786edc02440f371b776a417c973">CY_HPPASS_SAR_AVG_DISABLED</a>,</div><div class="line">    .limit = <a class="code" href="group__group__hppass__sar__enums.html#gga761a8378e0f3b0eab1a27f8617d1c02eae8979b0849935acf47a6057472a8c377">CY_HPPASS_SAR_LIMIT_DISABLED</a>,</div><div class="line">    .result   = <span class="keyword">true</span>,</div><div class="line">    .fifo  = <a class="code" href="group__group__hppass__sar__enums.html#ggaf90fa2a37e0fb7ef39e80b0c8c3179e9a27b52f62b23dd390c0f3317d106ade34">CY_HPPASS_FIFO_DISABLED</a></div><div class="line">};</div><div class="line"></div><div class="line"><span class="keyword">const</span> <a class="code" href="structcy__stc__hppass__sar__chan__t.html">cy_stc_hppass_sar_chan_t</a> chanCfg0 =</div><div class="line">{</div><div class="line">    .<a class="code" href="structcy__stc__hppass__sar__chan__t.html#a3cc40a1a5f02a50081870b542d4525b3">diff</a>     = <span class="keyword">false</span>,</div><div class="line">    .sign     = <span class="keyword">false</span>,</div><div class="line">    .avg      = <a class="code" href="group__group__hppass__sar__enums.html#ggae2f7574296597739ca43f2196bab0853a92843786edc02440f371b776a417c973">CY_HPPASS_SAR_AVG_DISABLED</a>,</div><div class="line">    .limit = <a class="code" href="group__group__hppass__sar__enums.html#gga761a8378e0f3b0eab1a27f8617d1c02eacf497e8f207755a56eb2e94972a424f0">CY_HPPASS_SAR_LIMIT_0</a>,</div><div class="line">    .result   = <span class="keyword">true</span>,</div><div class="line">    .fifo  = <a class="code" href="group__group__hppass__sar__enums.html#ggaf90fa2a37e0fb7ef39e80b0c8c3179e9a27b52f62b23dd390c0f3317d106ade34">CY_HPPASS_FIFO_DISABLED</a></div><div class="line">};</div></div><!-- fragment --><p>That configurations must be also included in the fields of the SAR configuration structure (<a class="el" href="structcy__stc__hppass__sar__t.html">cy_stc_hppass_sar_t</a>): </p><div class="fragment"><div class="line">    .chan        = {&amp;chanCfg0, &amp;chanCfg1, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg,</div><div class="line">                    &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg, &amp;chanCfg},</div><div class="line">    .grp         = {&amp;grpCfg0, &amp;grpCfg1, &amp;grpCfg2, &amp;grpCfg3, &amp;grpCfg4, &amp;grpCfg5, &amp;grpCfg6, &amp;grpCfg7},</div><div class="line">    .<a class="code" href="structcy__stc__hppass__sar__chan__t.html#a53ef8c47117f0c1104db31c1d20894a5">limit</a>       = {&amp;limitCfg0, &amp;limitCfg1, NULL, NULL, NULL, NULL, NULL, NULL},</div></div><!-- fragment --> <h1><a class="anchor" id="fifo_interrupts"></a>
FIFO Interrupts</h1>
<p>Using FIFO with MTB Device Configurator, since the FIFO has a single interrupt vector and need to be integrated with different solution personalities (like Motor Control) the Device Configurator itself generates the interrupt handler for entire FIFO with possibility to register individual callback for each FIFO buffer. See the generated source cycfg_peripherals.c for details. The runtime FIFO interrupt control can be done by the <a class="el" href="group__group__hppass__sar__fifo.html#ga72012349c483c5a88064db46507a9289">Cy_HPPASS_FIFO_SetInterruptMask</a>. The Device Configurator also generates the CYCFG_HPPASS_FIFO_INTR definition - the mask of all the used FIFO interrupt flags, which can be used with <a class="el" href="group__group__hppass__sar__fifo.html#ga72012349c483c5a88064db46507a9289">Cy_HPPASS_FIFO_SetInterruptMask</a>. When the HPPASS configurator 'start' feature is used - the Cy_HPPASS_FIFO_SetInterruptMask(CYCFG_HPPASS_FIFO_INTR) shall be called automatically during the generated init_cycfg_peripherals(); execution. </p><div class="image">
<img src="hppass_fifo_intr.png" alt="hppass_fifo_intr.png"/>
</div>
<p> The Device Configurator generated HPPASS FIFO interrupt priority is 0 (because it is intended to drive the solution fast control loop), however it could be changed manually in the generated cycfg_HPPASS_FIFO_interrupt structure before the generated cycfg_HPPASS_FIFO_ISR_Init() execution (when the HPPASS Startup Initialize feature is disabled).</p>
<h1><a class="anchor" id="FIR_Filter_Design"></a>
FIR Filter Design</h1>
<p>The finite impulse response (FIR) is a generalized filter structure that allows getting all of the basic response types through varying its coefficients. Although the FIR structure allows implementing Low-pass filter (LPF), High-pass filter (HPF), Band-pass filter (BPF), and Band-stop filter (BSF), the recommended filter implementation in HPPASS CSG module is the LPF. Such a recommendation is based on a hardware HPPASS SAR FIR limitation, which is a maximum number of tap count equal to 16 taps. You can use any available FIR Calculator or FIR Design Tool for coefficient determination.<br />
 However, the chosen tool must allow you to:</p><ul>
<li>Configure the filter response type to Low-pass.</li>
<li>Specify the Taps Quantity or Filter Order.</li>
<li>Set the Sample Frequency.</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>The term <b><em>Tap Quantity</em></b> is similar to the <b><em>Filter Length</em></b> and is equal to the number of multipliers or coefficients in its structure.<br />
 The term <b><em>Filter Order</em></b> determines the number of states or input signal delays in the filter structure and is equal to the adders quantity.<br />
 The Filter Order can be calculated as follows: <div class="fragment"><div class="line">FilterOrder = TapsQuantity - 1</div></div><!-- fragment --></dd></dl>
<p>There are various methods for FIR filter design to calculate FIR coefficients. Some tools allow you to choose the design method, but regardless of the exact chosen method, most FIR design tools require determining the desired frequency response parameters.<br />
 Generally, in case of the LPF FIR design that will be: </p><ul>
<li><b>The frequency specifications:</b><ul>
<li><b><em>Passband or Pass Frequency.</em></b> The passband is the frequency range where the signal passes through the filter with minimal attenuation. If only the Pass Frequency parameter is given, it implies that the passband starts from zero frequency and extends up to the specified Pass Frequency.</li>
<li><b><em>Stopband or Stop Frequency.</em></b> The stopband is the frequency range where the signal is significantly attenuated or blocked by the filter. If only the Stop Frequency parameter is given, it implies that the stopband starts from the specified Stop Frequency and extends up to half of the sample frequency (Nyquist frequency).</li>
<li>Less often either in addition to or instead of the passband and stopband the <b><em>Transition Band</em></b> parameter could be present. The transition band lies between the passband and stopband. In this region, the filter's frequency response changes from minimal attenuation (in the passband) to significant attenuation (in the stopband). </li>
</ul>
</li>
<li><b>The magnitude specifications:</b><ul>
<li><b><em>Passband Ripple.</em></b> This parameter defines the allowed ripple (variation in dB) within the passband.</li>
<li><b><em>Stopband Attenuation.</em></b> It specifies the minimum attenuation (in dB) required in the stopband.</li>
</ul>
</li>
</ul>
<div class="image">
<img src="hppass_fir_frequency_response.png" alt="hppass_fir_frequency_response.png"/>
</div>
<p>The design method and parameters chosen ultimately determine the values of the filter coefficients.<br />
 After configuring the FIR filter and calculating the coefficients, you must check the obtained coefficient values. Due to the hardware HPPASS SAR FIR limitation, all filter coefficients must satisfy the conditions: </p><div class="fragment"><div class="line">(abs(Coef[0..15]) &lt; 1) &amp;&amp; (sum(abs(Coef[0..15])) &lt; 8)</div></div><!-- fragment --><p> If the obtained coefficients didn't comply with these conditions, you must change the FIR filter configurations. The most impact parameters to change the coefficients' values are the Sample Frequency and Transition Band width.<br />
 After calculating the coefficients and verifying the conditions, you must convert the floating-point coefficients to a fixed-point representation supported by the hardware.<br />
 The HPPASS SAR FIR stores its coefficients in the less significant 16 bits of the 32-bit registers in Q15 fixed-point format. </p><dl class="section note"><dt>Note</dt><dd>The <b><em>Q15 fixed-point format</em></b> implies that the 15 less significant bits of the number represent its fractional part. Because the whole coefficient is a 16-bit value,<br />
 and 15 bits are reserved for the fractional part, the most significant bit is used as a sign extension. That is why the coefficients of the HPPASS SAR FIR cannot have an<br />
 integer part and their absolute value must be less than one, and the accurate coefficient values range is from -1 to 1-1/2^15.<br />
</dd></dl>
<p>To convert the floating-point coefficients to a Q15 fixed-point representation, use the equation below: </p><div class="fragment"><div class="line">Q15coef = round(DECcoef * 2^15)</div></div><!-- fragment --> <table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="groups"></a>
API Reference</h2></td></tr>
<tr class="memitem:group__group__hppass__sar__macros"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hppass__sar__macros.html">Macros</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__group__hppass__sar__functions"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hppass__sar__functions.html">Functions</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__group__hppass__sar__data__structures"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hppass__sar__data__structures.html">Data Structures</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__group__hppass__sar__enums"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hppass__sar__enums.html">Enumerated Types</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>MTB CAT1 Peripheral driver library</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
